'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url admin/dls/kh/sjkb/save_data 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		const db = uniCloud.database();
		let {
			data = {}, userInfo, util, filterResponse, originalParam
		} = event;
		let {
			customUtil,
			uniID,
			config,
			pubFun,
			vk,
			_
		} = util;
		let {
			uid,
			topdata,
			last_StartTime
		} = data;
		let res = {
			code: 0,
			msg: ""
		};
		// 业务逻辑开始-----------------------------------------------------------

		console.log("topdata=", topdata);
		let yesterday = vk.pubfn.timeFormat(last_StartTime, "yyyy-MM-dd");
		let add_datas = await db.collection('a_datas').add({
			date: yesterday,
			drxh: topdata.jrxh || 0, //当日消耗
			drcz: topdata.last_jrczje || 0, //当日充值金额
			jrroi: topdata.last_jrroi || 0, //当日roi
			srroi: topdata.last_srroi || 0, //首日roi
			gzcb: 0, //关注成本
			xyhffcb: topdata.last_xyhffcb || 0, //新用户付费成本
			xyhffupz: topdata.last_xyhffupz || 0, //新用户付费up值
			xyhffl: topdata.last_xyhffl || 0, //新用户付费率
			xyhs: topdata.last_xyhs || 0, //新用户数
			xyhczje: topdata.last_xyhczje || 0, //新用户充值金额
			xyhczrs: topdata.last_xyhczrs || 0, //新用户充值人数
			// xyhczbs: topdata.jrxh,//新用户充值笔数
			drczrs: topdata.last_jrczrs || 0, //当日充值人数
			drczbs: topdata.last_jrczbs || 0, //昨日充值笔数
			hcbs: topdata.last_hcbs || 0, //回传笔数
			hcje: topdata.last_hcje || 0, //回传金额
			agent_id: userInfo._id, //用户ID
			agent_username: userInfo.username, //用户名
			remark1: userInfo.remark1 || "", //备注1-描述
			remark2: userInfo.remark2 || "", //备注1-广告账户ID
			remark3: userInfo.remark3 || "", //备注1-投放链接
			_add_time: new Date().getTime(),
			_add_time_str: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd hh:mm:ss")

		})

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
